
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;


public class Manager {

	private Worker worker;   
	private OrderList allOrders;

	private ItemList allItems;


	public Manager()
	{
		allOrders = new  OrderList();


		allItems=new ItemList();

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Manager manager = new Manager();
		manager.run();
	}

	public void run(){
		this.initialise();
		this.process();	

	}

	public void initialise(){
		try {
			Scanner scanner = new Scanner (new File("Orders.txt"));
			while(scanner.hasNext()){  
				String inputLine = scanner.nextLine();
				//probably need to do something with the line here
				Order order= new Order (inputLine);
				//add to list
				if(!allOrders.checkEquality(order)){
					if(!order.getOrderID().equals("Wrong")){
						allOrders.addDetails(order);
					}
				}
			}
			Scanner scanner2 = new Scanner (new File("Items.txt"));
			while(scanner2.hasNext()){  
				String inputLine = scanner2.nextLine();
				String parts1 [] = inputLine.split(",");
				String id=parts1[0].trim();
				String colour=parts1[1].trim();
				String type=parts1[2].trim();
				String buttons=parts1[3].trim();
				int buttonNum=Integer.parseInt(buttons);
				String price=parts1[4].trim();
				String quantity=parts1[5].trim();

				//probably need to do something with the line here
				Mouse m= new Mouse (id,price,quantity,type,buttonNum,colour);
				//add to list
				if (!allItems.keyExists(id)){
					if (!m.getItemID().equals("Wrong")){
						allItems.addDetails(m.getItemID(),m);
					}
				}
			}   

		}
		catch (FileNotFoundException e) {
			System.out.println("File has not been found. ");
		}


	}


	//the worker works through the orders
	public void process() {
		worker = new Worker (allOrders,allItems);
		worker.run();

	}

}

